{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Abalone age predictor using tf.layers\n",
    "\n",
    "This tutorial covers how to create your own training script using the building\n",
    "blocks provided in `tf.layers`, which will predict the ages of\n",
    "[abalones](https://en.wikipedia.org/wiki/Abalone) based on their physical\n",
    "measurements. You'll learn how to do the following:\n",
    "\n",
    "*   Instantiate an `sagemaker.Estimator`\n",
    "*   Construct a custom model function\n",
    "*   Configure a neural network using `tf.feature_column` and `tf.layers`\n",
    "*   Choose an appropriate loss function from `tf.losses`\n",
    "*   Define a training op for your model\n",
    "*   Generate and return predictions"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## An Abalone Age Predictor\n",
    "\n",
    "It's possible to estimate the age of an\n",
    "[abalone](https://en.wikipedia.org/wiki/Abalone) (sea snail) by the number of\n",
    "rings on its shell. However, because this task requires cutting, staining, and\n",
    "viewing the shell under a microscope, it's desirable to find other measurements\n",
    "that can predict age.\n",
    "\n",
    "The [Abalone Data Set](https://archive.ics.uci.edu/ml/datasets/Abalone) contains\n",
    "the following\n",
    "[feature data](https://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.names)\n",
    "for abalone:\n",
    "\n",
    "| Feature        | Description                                               |\n",
    "| -------------- | --------------------------------------------------------- |\n",
    "| Length         | Length of abalone (in longest direction; in mm)           |\n",
    "| Diameter       | Diameter of abalone (measurement perpendicular to length; in mm)|\n",
    "| Height         | Height of abalone (with its meat inside shell; in mm)     |\n",
    "| Whole Weight   | Weight of entire abalone (in grams)                       |\n",
    "| Shucked Weight | Weight of abalone meat only (in grams)                    |\n",
    "| Viscera Weight | Gut weight of abalone (in grams), after bleeding          |\n",
    "| Shell Weight   | Weight of dried abalone shell (in grams)                  |\n",
    "\n",
    "The label to predict is number of rings, as a proxy for abalone age."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Set up the environment"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import sagemaker\n",
    "from sagemaker import get_execution_role\n",
    "\n",
    "sagemaker_session = sagemaker.Session()\n",
    "\n",
    "role = get_execution_role()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Upload the data to a S3 bucket"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "inputs = sagemaker_session.upload_data(path='data', key_prefix='data/DEMO-abalone')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**sagemaker_session.upload_data** will upload the abalone dataset from your machine to a bucket named **sagemaker-{region}-{your aws account number}**, if you don't have this bucket yet, sagemaker_session will create it for you."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Complete source code\n",
    "Here is the full code for the network model:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "!cat 'abalone.py'"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Constructing the `model_fn`\n",
    "\n",
    "The basic skeleton for an model function looks like this:\n",
    "\n",
    "```python\n",
    "def model_fn(features, labels, mode, hyperparameters):\n",
    "   # Logic to do the following:\n",
    "   # 1. Configure the model via TensorFlow operations\n",
    "   # 2. Define the loss function for training/evaluation\n",
    "   # 3. Define the training operation/optimizer\n",
    "   # 4. Generate predictions\n",
    "   # 5. Return predictions/loss/train_op/eval_metric_ops in EstimatorSpec object\n",
    "   return EstimatorSpec(mode, predictions, loss, train_op, eval_metric_ops)\n",
    "```\n",
    "\n",
    "The **`model_fn`** requires three arguments:\n",
    "\n",
    "*   **`features`**: A dict containing the features passed to the model via\n",
    "    **`input_fn`**.\n",
    "*   **`labels`**: A `Tensor` containing the labels passed to the model via\n",
    "    **`input_fn`**. Will be empty for `predict()` calls, as these are the values the\n",
    "    model will infer.\n",
    "*   **`mode`**: One of the following tf.estimator.ModeKeys string values\n",
    "    indicating the context in which the model_fn was invoked:\n",
    "    *   **`TRAIN`** The **`model_fn`** was invoked in training\n",
    "        mode, namely via a `train()` call.\n",
    "    *   **`EVAL`** The **`model_fn`** was invoked in\n",
    "        evaluation mode, namely via an `evaluate()` call.\n",
    "    *   **`PREDICT`** The **`model_fn`** was invoked in\n",
    "        predict mode, namely via a `predict()` call.\n",
    "\n",
    "**`model_fn`** may also accept a **`hyperparameters`** argument containing a dict of\n",
    "hyperparameters used for training (as shown in the skeleton above).\n",
    "\n",
    "The body of the function performs the following tasks (described in detail in the\n",
    "sections that follow):\n",
    "\n",
    "*   Configuring the model for the abalone predictor, this will be a neural\n",
    "    network.\n",
    "*   Defining the loss function used to calculate how closely the model's\n",
    "    predictions match the target values.\n",
    "*   Defining the training operation that specifies the `optimizer` algorithm to\n",
    "    minimize the loss values calculated by the loss function."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The **`model_fn`** must return a tf.estimator.EstimatorSpec\n",
    "object, which contains the following values:\n",
    "\n",
    "*   **`mode`** (required). The mode in which the model was run. Typically, you will\n",
    "    return the `mode` argument of the `model_fn` here.\n",
    "\n",
    "*   **`predictions`** (required in `PREDICT` mode). A dict that maps key names of\n",
    "    your choice to `Tensor`s containing the predictions from the model, e.g.:\n",
    "\n",
    "    ```python\n",
    "    predictions = {\"results\": tensor_of_predictions}\n",
    "    ```\n",
    "\n",
    "    In `PREDICT` mode, the dict that you return in `EstimatorSpec` will then be\n",
    "    returned by `predict()`, so you can construct it in the format in which\n",
    "    you'd like to consume it.\n",
    "\n",
    "\n",
    "*   **`loss`** (required in `EVAL` and `TRAIN` mode). A `Tensor` containing a scalar\n",
    "    loss value: the output of the model's loss function (discussed in more depth\n",
    "    later in Defining loss for the model calculated over all\n",
    "    the input examples. This is used in `TRAIN` mode for error handling and\n",
    "    logging, and is automatically included as a metric in `EVAL` mode.\n",
    "\n",
    "*   **`train_op`** (required only in `TRAIN` mode). An Op that runs one step of\n",
    "    training.\n",
    "\n",
    "*   **`eval_metric_ops`** (optional). A dict of name/value pairs specifying the\n",
    "    metrics that will be calculated when the model runs in `EVAL` mode. The name\n",
    "    is a label of your choice for the metric, and the value is the result of\n",
    "    your metric calculation. The tf.metrics\n",
    "    module provides predefined functions for a variety of common metrics. The\n",
    "    following `eval_metric_ops` contains an `\"accuracy\"` metric calculated using\n",
    "    `tf.metrics.accuracy`:\n",
    "\n",
    "    ```python\n",
    "    eval_metric_ops = {\n",
    "        \"accuracy\": tf.metrics.accuracy(labels, predictions)\n",
    "    }\n",
    "    ```\n",
    "\n",
    "    If you do not specify `eval_metric_ops`, only `loss` will be calculated\n",
    "    during evaluation."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Configuring a neural network with `tf.feature_column` and `tf.layers`\n",
    "\n",
    "Constructing a [neural\n",
    "network](https://en.wikipedia.org/wiki/Artificial_neural_network) entails\n",
    "creating and connecting the input layer, the hidden layers, and the output\n",
    "layer.\n",
    "\n",
    "The input layer is a series of nodes (one for each feature in the model) that\n",
    "will accept the feature data that is passed to the `model_fn` in the `features`\n",
    "argument. If `features` contains an n-dimensional `Tensor` with all your feature\n",
    "data, then it can serve as the input layer.\n",
    "If `features` contains a dict of feature columns passed to\n",
    "the model via an input function, you can convert it to an input-layer `Tensor`\n",
    "with the tf.feature_column.input_layer function.\n",
    "\n",
    "```python\n",
    "input_layer = tf.feature_column.input_layer(features=features, feature_columns=[age, height, weight])\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As shown above, **`input_layer()`** takes two required arguments:\n",
    "\n",
    "*   **`features`**. A mapping from string keys to the `Tensors` containing the\n",
    "    corresponding feature data. This is exactly what is passed to the `model_fn`\n",
    "    in the `features` argument.\n",
    "*   **`feature_columns`**. A list of all the `FeatureColumns`: `age`,\n",
    "    `height`, and `weight` in the above example.\n",
    "\n",
    "The input layer of the neural network then must be connected to one or more\n",
    "hidden layers via an [activation\n",
    "function](https://en.wikipedia.org/wiki/Activation_function) that performs a\n",
    "nonlinear transformation on the data from the previous layer. The last hidden\n",
    "layer is then connected to the output layer, the final layer in the model.\n",
    "`tf.layers` provides the `tf.layers.dense` function for constructing fully\n",
    "connected layers. The activation is controlled by the `activation` argument.\n",
    "Some options to pass to the `activation` argument are:\n",
    "\n",
    "*   **`tf.nn.relu`**. The following code creates a layer of `units` nodes fully\n",
    "    connected to the previous layer `input_layer` with a\n",
    "    [ReLU activation function](https://en.wikipedia.org/wiki/Rectifier_\\(neural_networks\\))\n",
    "    (tf.nn.relu):\n",
    "\n",
    "    ```python\n",
    "    hidden_layer = tf.layers.dense(\n",
    "        inputs=input_layer, units=10, activation=tf.nn.relu)\n",
    "    ```\n",
    "\n",
    "*   **`tf.nn.relu`**. The following code creates a layer of `units` nodes fully\n",
    "    connected to the previous layer `hidden_layer` with a ReLU activation\n",
    "    function:\n",
    "\n",
    "    ```python\n",
    "    second_hidden_layer = tf.layers.dense(\n",
    "        inputs=hidden_layer, units=20, activation=tf.nn.relu)\n",
    "    ```\n",
    "\n",
    "*   **`None`**. The following code creates a layer of `units` nodes fully connected\n",
    "    to the previous layer `second_hidden_layer` with *no* activation function,\n",
    "    just a linear transformation:\n",
    "\n",
    "    ```python\n",
    "    output_layer = tf.layers.dense(\n",
    "        inputs=second_hidden_layer, units=3, activation=None)\n",
    "    ```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Other activation functions are possible, e.g.:\n",
    "\n",
    "```python\n",
    "output_layer = tf.layers.dense(inputs=second_hidden_layer,\n",
    "                               units=10,\n",
    "                               activation_fn=tf.sigmoid)\n",
    "```\n",
    "\n",
    "The above code creates the neural network layer `output_layer`, which is fully\n",
    "connected to `second_hidden_layer` with a sigmoid activation function\n",
    "(tf.sigmoid).\n",
    "\n",
    "Putting it all together, the following code constructs a full neural network for\n",
    "the abalone predictor, and captures its predictions:\n",
    "\n",
    "```python\n",
    "def model_fn(features, labels, mode, params):\n",
    "  \"\"\"Model function for Estimator.\"\"\"\n",
    "\n",
    "  # Connect the first hidden layer to input layer\n",
    "  # (features[\"x\"]) with relu activation\n",
    "  first_hidden_layer = tf.layers.dense(features[\"x\"], 10, activation=tf.nn.relu)\n",
    "\n",
    "  # Connect the second hidden layer to first hidden layer with relu\n",
    "  second_hidden_layer = tf.layers.dense(\n",
    "      first_hidden_layer, 10, activation=tf.nn.relu)\n",
    "\n",
    "  # Connect the output layer to second hidden layer (no activation fn)\n",
    "  output_layer = tf.layers.dense(second_hidden_layer, 1)\n",
    "\n",
    "  # Reshape output layer to 1-dim Tensor to return predictions\n",
    "  predictions = tf.reshape(output_layer, [-1])\n",
    "  predictions_dict = {\"ages\": predictions}\n",
    "  ...\n",
    "```\n",
    "\n",
    "Here, because you'll be passing the abalone `Datasets` using `numpy_input_fn`\n",
    "as shown below, `features` is a dict `{\"x\": data_tensor}`, so\n",
    "`features[\"x\"]` is the input layer. The network contains two hidden\n",
    "layers, each with 10 nodes and a ReLU activation function. The output layer\n",
    "contains no activation function, and is\n",
    "tf.reshape to a one-dimensional\n",
    "tensor to capture the model's predictions, which are stored in\n",
    "`predictions_dict`.\n",
    "\n",
    "### Defining loss for the model\n",
    "\n",
    "The `EstimatorSpec` returned by the `model_fn` must contain `loss`: a `Tensor`\n",
    "representing the loss value, which quantifies how well the model's predictions\n",
    "reflect the label values during training and evaluation runs. The tf.losses\n",
    "module provides convenience functions for calculating loss using a variety of\n",
    "metrics, including:\n",
    "\n",
    "*   `absolute_difference(labels, predictions)`. Calculates loss using the\n",
    "    [absolute-difference\n",
    "    formula](https://en.wikipedia.org/wiki/Deviation_\\(statistics\\)#Unsigned_or_absolute_deviation)\n",
    "    (also known as L<sub>1</sub> loss).\n",
    "\n",
    "*   `log_loss(labels, predictions)`. Calculates loss using the [logistic loss\n",
    "    forumula](https://en.wikipedia.org/wiki/Loss_functions_for_classification#Logistic_loss)\n",
    "    (typically used in logistic regression).\n",
    "\n",
    "*   `mean_squared_error(labels, predictions)`. Calculates loss using the [mean\n",
    "    squared error](https://en.wikipedia.org/wiki/Mean_squared_error) (MSE; also\n",
    "    known as L<sub>2</sub> loss).\n",
    "\n",
    "The following example adds a definition for `loss` to the abalone `model_fn`\n",
    "using `mean_squared_error()`:"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "```python\n",
    "def model_fn(features, labels, mode, params):\n",
    "  \"\"\"Model function for Estimator.\"\"\"\n",
    "\n",
    "  # Connect the first hidden layer to input layer\n",
    "  # (features[\"x\"]) with relu activation\n",
    "  first_hidden_layer = tf.layers.dense(features[\"x\"], 10, activation=tf.nn.relu)\n",
    "\n",
    "  # Connect the second hidden layer to first hidden layer with relu\n",
    "  second_hidden_layer = tf.layers.dense(\n",
    "      first_hidden_layer, 10, activation=tf.nn.relu)\n",
    "\n",
    "  # Connect the output layer to second hidden layer (no activation fn)\n",
    "  output_layer = tf.layers.dense(second_hidden_layer, 1)\n",
    "\n",
    "  # Reshape output layer to 1-dim Tensor to return predictions\n",
    "  predictions = tf.reshape(output_layer, [-1])\n",
    "  predictions_dict = {\"ages\": predictions}\n",
    "\n",
    "\n",
    "  # Calculate loss using mean squared error\n",
    "  loss = tf.losses.mean_squared_error(labels, predictions)\n",
    "  ...\n",
    "```\n",
    "\n",
    "See the [tf.losses](https://www.tensorflow.org/api_docs/python/tf/losses) for a\n",
    "full list of loss functions and more details on supported arguments and usage.\n",
    "\n",
    "Supplementary metrics for evaluation can be added to an `eval_metric_ops` dict.\n",
    "The following code defines an `rmse` metric, which calculates the root mean\n",
    "squared error for the model predictions. Note that the `labels` tensor is cast\n",
    "to a `float64` type to match the data type of the `predictions` tensor, which\n",
    "will contain real values:\n",
    "\n",
    "```python\n",
    "eval_metric_ops = {\n",
    "    \"rmse\": tf.metrics.root_mean_squared_error(\n",
    "        tf.cast(labels, tf.float64), predictions)\n",
    "}\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Defining the training op for the model\n",
    "\n",
    "The training op defines the optimization algorithm TensorFlow will use when\n",
    "fitting the model to the training data. Typically when training, the goal is to\n",
    "minimize loss. A simple way to create the training op is to instantiate a\n",
    "`tf.train.Optimizer` subclass and call the `minimize` method.\n",
    "\n",
    "The following code defines a training op for the abalone `model_fn` using the\n",
    "loss value calculated in [Defining Loss for the Model](https://github.com/tensorflow/tensorflow/blob/eb84435170c694175e38bfa02751c3ef881c7a20/tensorflow/docs_src/extend/estimators.md#defining-loss), the\n",
    "learning rate passed to the function in `params`, and the gradient descent\n",
    "optimizer. For `global_step`, the convenience function\n",
    "tf.train.get_global_step takes care of generating an integer variable:\n",
    "\n",
    "```python\n",
    "optimizer = tf.train.GradientDescentOptimizer(\n",
    "    learning_rate=params[\"learning_rate\"])\n",
    "train_op = optimizer.minimize(\n",
    "    loss=loss, global_step=tf.train.get_global_step())\n",
    "```\n",
    "\n",
    "### The complete abalone `model_fn`\n",
    "\n",
    "Here's the final, complete `model_fn` for the abalone age predictor. The\n",
    "following code configures the neural network; defines loss and the training op;\n",
    "and returns a `EstimatorSpec` object containing `mode`, `predictions_dict`, `loss`,\n",
    "and `train_op`:\n",
    "\n",
    "```python\n",
    "def model_fn(features, labels, mode, params):\n",
    "  \"\"\"Model function for Estimator.\"\"\"\n",
    "\n",
    "  # Connect the first hidden layer to input layer\n",
    "  # (features[\"x\"]) with relu activation\n",
    "  first_hidden_layer = tf.layers.dense(features[\"x\"], 10, activation=tf.nn.relu)\n",
    "\n",
    "  # Connect the second hidden layer to first hidden layer with relu\n",
    "  second_hidden_layer = tf.layers.dense(\n",
    "      first_hidden_layer, 10, activation=tf.nn.relu)\n",
    "\n",
    "  # Connect the output layer to second hidden layer (no activation fn)\n",
    "  output_layer = tf.layers.dense(second_hidden_layer, 1)\n",
    "\n",
    "  # Reshape output layer to 1-dim Tensor to return predictions\n",
    "  predictions = tf.reshape(output_layer, [-1])\n",
    "\n",
    "  # Provide an estimator spec for `ModeKeys.PREDICT`.\n",
    "  if mode == tf.estimator.ModeKeys.PREDICT:\n",
    "    return tf.estimator.EstimatorSpec(\n",
    "        mode=mode,\n",
    "        predictions={\"ages\": predictions})\n",
    "\n",
    "  # Calculate loss using mean squared error\n",
    "  loss = tf.losses.mean_squared_error(labels, predictions)\n",
    "\n",
    "  # Calculate root mean squared error as additional eval metric\n",
    "  eval_metric_ops = {\n",
    "      \"rmse\": tf.metrics.root_mean_squared_error(\n",
    "          tf.cast(labels, tf.float64), predictions)\n",
    "  }\n",
    "\n",
    "  optimizer = tf.train.GradientDescentOptimizer(\n",
    "      learning_rate=params[\"learning_rate\"])\n",
    "  train_op = optimizer.minimize(\n",
    "      loss=loss, global_step=tf.train.get_global_step())\n",
    "\n",
    "  # Provide an estimator spec for `ModeKeys.EVAL` and `ModeKeys.TRAIN` modes.\n",
    "  return tf.estimator.EstimatorSpec(\n",
    "      mode=mode,\n",
    "      loss=loss,\n",
    "      train_op=train_op,\n",
    "      eval_metric_ops=eval_metric_ops)\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Submitting script for training"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "from sagemaker.tensorflow import TensorFlow\n",
    "\n",
    "abalone_estimator = TensorFlow(entry_point='abalone.py',\n",
    "                               role=role,\n",
    "                               framework_version='1.12.0',\n",
    "                               training_steps= 100,                                  \n",
    "                               evaluation_steps= 100,\n",
    "                               hyperparameters={'learning_rate': 0.001},\n",
    "                               train_instance_count=1,\n",
    "                               train_instance_type='ml.c4.xlarge')\n",
    "\n",
    "abalone_estimator.fit(inputs)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`estimator.fit` will deploy a script in a container for training and returs the SageMaker model name using the following arguments:\n",
    "\n",
    "*   **`entry_point=\"abalone.py\"`** The path to the script that will be deployed to the container.\n",
    "*   **`training_steps=100`** The number of training steps of the training job.\n",
    "*   **`evaluation_steps=100`** The number of evaluation steps of the training job.\n",
    "*   **`role`**. AWS role that gives your account access to SageMaker training and hosting\n",
    "*   **`hyperparameters={'learning_rate' : 0.001}`**. Training hyperparameters. \n",
    "\n",
    "Running the code block above will do the following actions:\n",
    "* deploy your script in a container with tensorflow installed\n",
    "* copy the data from the bucket to the container\n",
    "* instantiate the tf.estimator\n",
    "* train the estimator with 100 training steps\n",
    "* save the estimator model"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Submiting a trained model for hosting\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "abalone_predictor = abalone_estimator.deploy(initial_instance_count=1, instance_type='ml.m4.xlarge')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "`abalone_estimator.deploy` deploys the trained model in a container ready for production."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Invoking the endpoint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "\n",
    "prediction_set = tf.contrib.learn.datasets.base.load_csv_without_header(\n",
    "    filename=os.path.join('data/abalone_predict.csv'), target_dtype=np.int, features_dtype=np.float32)\n",
    "\n",
    "data = prediction_set.data[0]\n",
    "tensor_proto = tf.make_tensor_proto(values=np.asarray(data), shape=[1, len(data)], dtype=tf.float32)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "abalone_predictor.predict(tensor_proto)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Deleting the endpoint"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sagemaker.Session().delete_endpoint(abalone_predictor.endpoint)"
   ]
  }
 ],
 "metadata": {
  "notice": "Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.  Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.",
  "kernelspec": {
   "display_name": "Environment (conda_tensorflow_p27)",
   "language": "python",
   "name": "conda_tensorflow_p27"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
